/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entidades;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author lomanda
 */
@Entity
@Table(name = "contas")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Contas.findAll", query = "SELECT c FROM Contas c"),
    @NamedQuery(name = "Contas.findByIdConta", query = "SELECT c FROM Contas c WHERE c.idConta = :idConta"),
    @NamedQuery(name = "Contas.findByDescricao", query = "SELECT c FROM Contas c WHERE c.descricao = :descricao"),
    @NamedQuery(name = "Contas.findByNivel", query = "SELECT c FROM Contas c WHERE c.nivel = :nivel"),
    @NamedQuery(name = "Contas.findByQuantia", query = "SELECT c FROM Contas c WHERE c.quantia = :quantia")})
public class Contas implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "idConta")
    private Integer idConta;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "descricao")
    private String descricao;
    @Column(name = "nivel")
    private Integer nivel;
    @Basic(optional = false)
    @NotNull
    @Column(name = "quantia")
    private double quantia;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "contaMae")
    private List<Contas> contasList;
    @JoinColumn(name = "contaMae", referencedColumnName = "idConta")
    @ManyToOne(optional = false)
    private Contas contaMae;
    @JoinColumn(name = "fkClasse", referencedColumnName = "idClasse")
    @ManyToOne(optional = false)
    private ClasseConta fkClasse;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fkContaDebitar")
    private List<Lancamentos> lancamentosList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fkContaCreditar")
    private List<Lancamentos> lancamentosList1;

    public Contas() {
    }

    public Contas(Integer idConta) {
        this.idConta = idConta;
    }

    public Contas(Integer idConta, String descricao, double quantia) {
        this.idConta = idConta;
        this.descricao = descricao;
        this.quantia = quantia;
    }

    public Integer getIdConta() {
        return idConta;
    }

    public void setIdConta(Integer idConta) {
        this.idConta = idConta;
    }

    public String getDescricao() {
        return descricao;
    }

    public void setDescricao(String descricao) {
        this.descricao = descricao;
    }

    public Integer getNivel() {
        return nivel;
    }

    public void setNivel(Integer nivel) {
        this.nivel = nivel;
    }

    public double getQuantia() {
        return quantia;
    }

    public void setQuantia(double quantia) {
        this.quantia = quantia;
    }

    @XmlTransient
    public List<Contas> getContasList() {
        return contasList;
    }

    public void setContasList(List<Contas> contasList) {
        this.contasList = contasList;
    }

    public Contas getContaMae() {
        return contaMae;
    }

    public void setContaMae(Contas contaMae) {
        this.contaMae = contaMae;
    }

    public ClasseConta getFkClasse() {
        return fkClasse;
    }

    public void setFkClasse(ClasseConta fkClasse) {
        this.fkClasse = fkClasse;
    }

    @XmlTransient
    public List<Lancamentos> getLancamentosList() {
        return lancamentosList;
    }

    public void setLancamentosList(List<Lancamentos> lancamentosList) {
        this.lancamentosList = lancamentosList;
    }

    @XmlTransient
    public List<Lancamentos> getLancamentosList1() {
        return lancamentosList1;
    }

    public void setLancamentosList1(List<Lancamentos> lancamentosList1) {
        this.lancamentosList1 = lancamentosList1;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idConta != null ? idConta.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Contas)) {
            return false;
        }
        Contas other = (Contas) object;
        if ((this.idConta == null && other.idConta != null) || (this.idConta != null && !this.idConta.equals(other.idConta))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidades.Contas[ idConta=" + idConta + " ]";
    }
    
}
